package com.wp.module.WpWallpaperColor.controller;

import com.wp.common.annotation.Log;
import com.wp.common.core.controller.BaseController;
import com.wp.common.core.domain.AjaxResult;
import com.wp.common.core.page.TableDataInfo;
import com.wp.common.enums.BusinessType;
import com.wp.common.utils.poi.ExcelUtil;
import com.wp.module.WpWallpaperColor.domain.WpWallpaperColor;
import com.wp.module.WpWallpaperColor.service.IWpWallpaperColorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 颜色类型Controller
 * 
 * @author wp
 * @date 2025-02-25
 */
@RestController
@RequestMapping("/module/wpWallpaperColor")
public class WpWallpaperColorController extends BaseController
{
    @Autowired
    private IWpWallpaperColorService wpWallpaperColorService;

    /**
     * 查询颜色类型列表
     */
    @PreAuthorize("@ss.hasPermi('module:wpWallpaperColor:list')")
    @GetMapping("/list")
    public TableDataInfo list(WpWallpaperColor wpWallpaperColor)
    {
        startPage();
        List<WpWallpaperColor> list = wpWallpaperColorService.selectWpWallpaperColorList(wpWallpaperColor);
        return getDataTable(list);
    }

    /**
     * 导出颜色类型列表
     */
    @PreAuthorize("@ss.hasPermi('module:wpWallpaperColor:export')")
    @Log(title = "颜色类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WpWallpaperColor wpWallpaperColor)
    {
        List<WpWallpaperColor> list = wpWallpaperColorService.selectWpWallpaperColorList(wpWallpaperColor);
        ExcelUtil<WpWallpaperColor> util = new ExcelUtil<WpWallpaperColor>(WpWallpaperColor.class);
        util.exportExcel(response, list, "颜色类型数据");
    }

    /**
     * 获取颜色类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:wpWallpaperColor:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(wpWallpaperColorService.selectWpWallpaperColorById(id));
    }

    /**
     * 新增颜色类型
     */
    @PreAuthorize("@ss.hasPermi('module:wpWallpaperColor:add')")
    @Log(title = "颜色类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WpWallpaperColor wpWallpaperColor)
    {
        return toAjax(wpWallpaperColorService.insertWpWallpaperColor(wpWallpaperColor));
    }

    /**
     * 修改颜色类型
     */
    @PreAuthorize("@ss.hasPermi('module:wpWallpaperColor:edit')")
    @Log(title = "颜色类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WpWallpaperColor wpWallpaperColor)
    {
        return toAjax(wpWallpaperColorService.updateWpWallpaperColor(wpWallpaperColor));
    }

    /**
     * 删除颜色类型
     */
    @PreAuthorize("@ss.hasPermi('module:wpWallpaperColor:remove')")
    @Log(title = "颜色类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(wpWallpaperColorService.deleteWpWallpaperColorByIds(ids));
    }
}
